while True:
    
    s = input("Введите скобочную последовательность\n")
    text = ''
    for x in s:
        if x=='(' or x == ')' or x == '['or x ==']'or x =='{' or x =='}' or x == '<' or x == '>':
            text+=x
    print(text)
    while '()' in text or '[]' in text or '{}' in text or '<>' in text:
        text = text.replace('()', '')
        text = text.replace('[]', '')
        text = text.replace('{}', '')
        text = text.replace('<>', '')
    if len(text)==0:
        print("True")
    else:
        print("False")
    print(text)
